package com.zl.gmadmin.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zl.gmadmin.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Optional;

/**
 * @author zhangliang
 * @version 1.0
 * @date 2021/2/20 17:22
 */
@Mapper
public interface SysDeptMapper extends BaseMapper<SysDept> {


    /**
     * 分页查询
     *
     * @return
     */
    IPage<SysDept> selectPageVo(Page<SysDept> page, @Param(Constants.WRAPPER) QueryWrapper<SysDept> queryWrapper);

    /**
     * 部门是否存在用户
     */
    List<SysDept> deptExistsUsers(List<Long> ids);


    /**
     * 查询同级部门最大排序号
     * @param pid
     * @return
     */
    Optional<Long> selectSameLevelDeptMaxSort(Long pid);
}
